<?php
	require_once(realpath(dirname(__FILE__)) . "/../pre.php");
	require_once(realpath(dirname(__FILE__)) . "/../auth.php");
require_once(realpath(dirname(__FILE__)) . "/../../fonctions/divers.php");
?>
<?php if(! est_autorise("acces_configuration")) exit; ?>
<?php
        require_once("../../classes/Transzone.class.php");
        require_once("../../classes/Zone.class.php");
		header('Content-Type: text/html; charset=utf-8');
?>

<?php
	if($_GET['action'] == "supprimer" && $_GET['zone'] != ""){
		$transzone = new Transzone();
		$transzone->charger_id($_GET['zone']);
		$transzone->delete();

	} else if($_GET['action'] == "ajouter" && $_GET['id'] != "" && $_GET['zone'] != ""){
		$transzone = new Transzone();
		$transzone->zone = $_GET['zone'];
		$transzone->transport = $_GET['id'];
		$transzone->add();

	}

	$zone = new Zone();
?>

		<div class="entete_liste_config" style="margin-top:15px;">
			<div class="titre"><?php echo trad('MODIFICATION_TRANSPORT'); ?></div>
		</div>

		<ul class="ligne1">
				<li style="width:250px;">
					<select class="form_select" id="zone">
					<?php
						$query = "select * from $zone->table";
						$resul = mysql_query($query, $transzone->link);
						while($row = mysql_fetch_object($resul)){
							$test = new Transzone();
							if(! $test->charger($_GET['id'], $row->id)){
					?>
			     	<option value="<?php echo $row->id; ?>"><?php echo $row->nom; ?></option>
			     	<?php
			     			}
			     		}
			     	?>
					</select>
				</li>
				<li><a href="javascript:ajouter($('#zone').val())"><?php echo trad('AJOUTER_ZONE'); ?></a></li>
		</ul>

<?php
			$query = "select * from $transzone->table where transport=\"" . $_GET['id']. "\"";
			$resul = mysql_query($query, $transzone->link);

			$i = 0;

			while($row = mysql_fetch_object($resul)){
				$zone = new Zone();
				$zone->charger($row->zone);
				if($i%2)
					$fond = "ligne_claire_transport";
				else
					$fond = "ligne_fonce_transport";

?>
		<ul class="<?php echo $fond; ?>">
				<li style="width:492px;"><?php echo $zone->nom; ?></li>
				<li style="width:32px;"><a href="javascript:supprimer(<?php echo $row->id; ?>)"><?php echo trad('Supprimer'); ?></a></li>
		</ul>
<?php
				$i++;
			}
?>